package day02;

import java.util.Scanner;

public class FindLis {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入数组大小");
        int n = sc.nextInt();
        int z=1,M=0,X=0;
        int [] a = new int[n];
        System.out.println("依次输入数列值");
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();

        }
//            求最长上升子列长度
        for (int t = 0; t < a.length-1; t++) {
            for (int i =t , j = i + 1; j < a.length ; j++) {
                if (a[i] < a[j]) {
                    z++;
                    i = j;
                }
            }
            System.out.println(z);
            if(M<z) {
                M = z;
                X=t;
            }
            z=1;
        }
        System.out.println("该数列的最长上升子列长度为"+M);
        //输出从下标X开始的上升序列，即为最长上升子序列
        System.out.print("该上升子列为："+a[X]+" ");
        for(int i=X+1;i<a.length;i++){
            if (a[X] < a[i]) {
                System.out.print(a[i]+" ");
                X=i;
            }

        }

    }
}
